import java.math.BigInteger;


public class P55 {
	private static boolean isLychrel(int n) {
		int count = 0;
		
		BigInteger x = new BigInteger(String.valueOf(n));
		
		while (true) {
			x = x.add(new BigInteger(Util.reverse(x)));
			count++;
			
			if (Util.isPalindromic(x)) {
				return false;
			}
			
			if (count >= 50) {
				return true;
			}
		}
	}
	
	public static void main(String[] args) {
		int count = 0;
		for (int i = 1; i <= 10000; i++) {
			if (isLychrel(i)) {
				System.out.println(i);
				count++;
			}
		}	
		System.out.println(count);
	}	
}